package com.LearnInWorld.video.controller;

import com.LearnInWorld.entity.Result;
import com.LearnInWorld.entity.StatusCode;
import com.LearnInWorld.video.pojo.Course;
import com.LearnInWorld.video.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/course")
public class CourseController {

    @Autowired
    private CourseService courseService;


    @RequestMapping("/findList")
    public Result<List<Course>> findLIst(){
       List<Course>courseInfoList= courseService.findAll();
       return new Result<List<Course>>(true, StatusCode.OK,"",courseInfoList);
    }

    @RequestMapping("/findCourse/{courseId}")
    public Result<Course> findCourseById(@PathVariable("courseId") String courseId){
        Course course=courseService.findCourseById(courseId);
        return new Result<>(true,StatusCode.OK,"",course);
    }


}
